package com.zhika.zishi.customview;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.zhika.zishi.R;
import com.zhika.zishi.activity.RecommendHomepageActivity;
import com.zhika.zishi.activity.NewStrategyActivity;
import com.zhika.zishi.activity.RemindActivity;

/**
 * Created by Michael on 2015/4/7.
 */
public class BottomView extends FrameLayout implements View.OnClickListener{

    private ImageButton leftImageButton;

    private ImageButton middleImageButton;

    private ImageButton rightImageButton;

    private LayoutInflater layoutInflater;

    private Context context;

    public BottomView(Context context){
       this(context,null);
    }

    public BottomView(Context context,AttributeSet attributeSet){
        this(context,attributeSet,0);
    }

    public BottomView(Context context,AttributeSet attributeSet,int defStyle){
        super(context,attributeSet,defStyle);
        layoutInflater = LayoutInflater.from(context);

        this.context = context;

        initView();
    }

    private void initView(){
        View view = layoutInflater.inflate(R.layout.bottom_view,this);
        leftImageButton = (ImageButton) view.findViewById(R.id.bottom_left_image_button);
        leftImageButton.setOnClickListener(this);

        middleImageButton = (ImageButton) view.findViewById(R.id.bottom_middle_image_button);
        middleImageButton.setOnClickListener(this);

        rightImageButton = (ImageButton) view.findViewById(R.id.bottom_right_image_button);
        rightImageButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bottom_left_image_button:
                Intent intent = new Intent(context, RecommendHomepageActivity.class);
                context.startActivity(intent);
                break;
            case R.id.bottom_middle_image_button:
                Intent intent2 = new Intent(context, NewStrategyActivity.class);
                context.startActivity(intent2);
                break;
            case R.id.bottom_right_image_button:
                Intent intent3 = new Intent(context, RemindActivity.class);
                context.startActivity(intent3);
                break;
            default:
                break;
        }
    }
}
